home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / BASIC / 2823.ZIP / DEMO.BAS < prev    next >
BASIC Source File  |  1990-12-10  |  7KB  |  218 lines

  1. '   +----------------------------------------------------------------------+
  2. '   |                                                                      |
  3. '   |          GRAFWIZ  Copyright (c) 1990  Thomas G. Hanlin III           |
  4. '   |                                                                      |
  5. '   |               The Graphics Wizard's Library for BASIC                |
  6. '   |                                                                      |
  7. '   +----------------------------------------------------------------------+
  8.  
  9.    REM $INCLUDE: 'grafwiz.bi'
  10.  
  11.    DEFINT A-Z
  12.  
  13.    DEF FNR (X) = INT(RND * X)
  14.  
  15.    RANDOMIZE TIMER
  16.  
  17.    GetDisplay Adapter, Mono
  18.  
  19.    IF Adapter < 3 THEN
  20.       PRINT "Sorry, but you must have a CGA, EGA or VGA display active to run this demo."
  21.       END
  22.    END IF
  23.  
  24.    G1Mode 1                          ' CGA 320x200 mode
  25.    G1PaletteA 0                      ' Green, Red, Yellow palette
  26.  
  27.    BFont 1
  28.    G1Color 1, 0
  29.    G1Banner "GRAFWIZ", 0, 0, 3, 2
  30.    BFont 0
  31.    G1Color 3, 0
  32.    G1Banner "Copyright (c)1990", 179, 5, 1, 1
  33.    G1Banner "Thomas G. Hanlin", 182, 15, 1, 1
  34.  
  35.    BFont 2
  36.    G1Color 2, 0
  37.    G1Banner "This is the Graphics Wizard's Library.", 0, 40, 1, 1
  38.  
  39.    BFont 1
  40.    G1Color 1, 0
  41.    G1Banner "Flexible text handling is a natural", 0, 68, 1, 1
  42.    G1Banner "aspect of graphics modes.  The GRAFWIZ", 0, 82, 1, 1
  43.    G1Banner "library takes full advantage of that,", 0, 96, 1, 1
  44.    G1Banner "with a selection of fonts and fast", 0, 110, 1, 1
  45.    G1Banner "full-color text support.", 0, 124, 1, 1
  46.  
  47.    BFont 0
  48.    G1Color 3, 0
  49.    G1Banner "This is CGA mode SCREEN 1, by the way.", 0, 150, 1, 1
  50.  
  51.    BFont 2
  52.    G1Color 2, 0
  53.    G1Banner "Now let's see some graphics!", 0, 170, 1, 1
  54.  
  55.    G1Locate 25, 14
  56.    G1Color 2, 3
  57.    G1Write "Press a key"
  58.  
  59.    DO
  60.    LOOP WHILE LEN(INKEY$)
  61.    DO
  62.       ky$ = INKEY$
  63.    LOOP UNTIL LEN(ky$)
  64.    IF ky$ = CHR$(27) THEN GOTO Done
  65.  
  66.    G1Color 0, 0
  67.    G1Box 0, 30, 319, 189, 1
  68.    G1Color 2, 0
  69.    G1Box 0, 26, 319, 188, 0
  70.  
  71.    G1Color 1, 0
  72.    G1Locate 23, 2
  73.    G1Write "Dots, Lines, Boxes, Ellipses..."
  74.  
  75.    FOR Dot = 1 TO 200
  76.       G1Color FNR(3) + 1, 0
  77.       G1Plot FNR(316) + 2, FNR(140) + 28
  78.    NEXT
  79.  
  80.    FOR Lin = 1 TO 10
  81.       G1Color FNR(3) + 1, 0
  82.       G1Line FNR(316) + 2, FNR(140) + 28, FNR(315) + 3, FNR(139) + 29
  83.    NEXT
  84.  
  85.    FOR Box = 1 TO 10
  86.       G1Color FNR(3) + 1, 0
  87.       X = FNR(250) + 2
  88.       Y = FNR(112) + 28
  89.       G1Box X, Y, X + FNR(60) + 1, Y + FNR(25) + 1, FNR(2)
  90.    NEXT
  91.  
  92.    FOR Ellipse = 1 TO 10
  93.       G1Color FNR(3) + 1, 0
  94.       X = FNR(215) + 40
  95.       Y = FNR(85) + 60
  96.       G1Ellipse X, Y, FNR(25) + 5, FNR(20) + 5
  97.    NEXT
  98.  
  99.    DO
  100.    LOOP WHILE LEN(INKEY$)
  101.    DO
  102.       ky$ = INKEY$
  103.    LOOP UNTIL LEN(ky$)
  104.    IF ky$ = CHR$(27) THEN GOTO Done
  105.  
  106.    G1Color 0, 0
  107.    G1Box 1, 27, 318, 187, 1
  108.  
  109.    G1Color 1, 0
  110.    G1Locate 23, 2
  111.    G1Write "But why stop at the usual?"
  112.  
  113.    FOR Poly = 1 TO 12
  114.       G1Color FNR(3) + 1, 0
  115.       X = FNR(212) + 40
  116.       Y = FNR(90) + 60
  117.       G1Polygon X, Y, FNR(25) + 5, FNR(6) + 3, 3.14159 * RND
  118.    NEXT
  119.  
  120.    DO
  121.    LOOP WHILE LEN(INKEY$)
  122.    DO
  123.       ky$ = INKEY$
  124.    LOOP UNTIL LEN(ky$)
  125.    IF ky$ = CHR$(27) THEN GOTO Done
  126.  
  127.    G2Mode 1                          ' CGA 640x200 mode
  128.    IF Adapter = 3 THEN               ' if CGA...
  129.       G1Border 1                     '    set foreground color to blue
  130.    END IF
  131.    G2Locate 1, 1
  132.    G2Color 1, 0
  133.    G2WriteLn "There are a few additional routines of interest which are designed to work"
  134.    G2WriteLn "only in SCREEN 2 mode at this time.  These are the picture readers, which"
  135.    G2WriteLn "allow you to read in .MAC and .PCX pictures into a GET/PUT image.  Here's"
  136.    G2WriteLn "a sample from DEMO.PCX:"
  137.  
  138.    REDIM Image(1)
  139.    G2LoadPCX "DEMO.PCX", Image(), ErrCode
  140.    G2Put 40, 40, Image()
  141.  
  142.    G2Locate 15, 1
  143.    G2WriteLn "Of course, that's not the end of it!  There are many other routines that"
  144.    G2WriteLn "are not included in this demonstration.  One of 'em in particular which you"
  145.    G2WriteLn "may like is a routine to print out a screen (almost any display mode) to"
  146.    G2WriteLn "any Epson-compatible printer.  Another allows you to detect what kind of"
  147.    G2WriteLn "display adapter is attached and whether the display is color or monochrome."
  148.    G2WriteLn ""
  149.    G2WriteLn "See GRAFWIZ.DOC for more details."
  150.  
  151.    G2Locate 25, 33
  152.    G2Color 0, 1
  153.    G2Write "Press any key"
  154.  
  155.    IF Adapter = 4 THEN                     ' if EGA...
  156.       DO
  157.       LOOP WHILE LEN(INKEY$)
  158.       DO
  159.          ky$ = INKEY$
  160.       LOOP UNTIL LEN(ky$)
  161.       IF ky$ = CHR$(27) THEN GOTO Done
  162.       G7Mode 1                             ' ...put into low-res EGA mode
  163.       G7Color 4, 2
  164.       G7WriteLn "Ah, I see you have an EGA!  Of course,"
  165.       G7Color 0, 3
  166.       G7WriteLn "GRAFWIZ supports the various EGA modes"
  167.       G7Color 7, 1
  168.       G7WriteLn "as well as the Hercules, CGA and VGA."
  169.       FOR Y = 0 TO 31
  170.          G7Color Y AND 15, 0
  171.          G7Box Y, Y + 64, 319 - Y, (64 - Y) + 120, (Y = 100)
  172.          IF Y > 15 THEN
  173.             G7Polygon Y * 15 - 194, 112, 5, FNR(6) + 3, .75 * 3.141593
  174.             G7Color ((Y XOR 15) AND 15), 0
  175.             G7Polygon Y * 15 - 194, 136, 5, FNR(6) + 3, 0
  176.          END IF
  177.       NEXT
  178.       G7Locate 25, 14
  179.       G7Color 15, 4
  180.       G7Write "Press any key"
  181.    ELSEIF Adapter = 6 THEN                     ' if VGA...
  182.       DO
  183.       LOOP WHILE LEN(INKEY$)
  184.       DO
  185.          ky$ = INKEY$
  186.       LOOP UNTIL LEN(ky$)
  187.       IF ky$ = CHR$(27) THEN GOTO Done
  188.       G13Mode 1                            ' ...put into low-res VGA mode
  189.       G13Color 4, 2
  190.       G13WriteLn "Ah, I see you have a VGA!  Of course,"
  191.       G13Color 0, 3
  192.       G13WriteLn "GRAFWIZ supports the various VGA modes"
  193.       G13Color 7, 1
  194.       G13WriteLn "as well as Hercules, CGA and EGA."
  195.       FOR Y = 0 TO 31
  196.          G13Color Y + 16, 0
  197.          G13Box Y, Y + 64, 319 - Y, (64 - Y) + 120, (Y = 100)
  198.          IF Y > 15 THEN
  199.             G13Polygon Y * 15 - 194, 112, 5, FNR(6) + 3, .75 * 3.141593
  200.             G13Color 64 - Y, 0
  201.             G13Polygon Y * 15 - 194, 136, 5, FNR(6) + 3, 0
  202.          END IF
  203.       NEXT
  204.       G13Locate 25, 14
  205.       G13Color 15, 4
  206.       G13Write "Press any key"
  207.    END IF
  208.  
  209.    DO
  210.    LOOP WHILE LEN(INKEY$)
  211.    DO
  212.       ky$ = INKEY$
  213.    LOOP UNTIL LEN(ky$)
  214.    IF ky$ = CHR$(27) THEN GOTO Done
  215.  
  216. Done:
  217.    G1Mode 0                          ' restore text mode
  218.